package com.ly.wxstore;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.aliyun.oss.OSSClient;
import com.aliyun.oss.model.Bucket;

/**
 * Simple demo of {@link com.alibaba.appengine.api.store.StoreService}
 *
 * @author ding.lid
 */
public class StoreServiceDemo extends HttpServlet {
	private static final long serialVersionUID = -235936632435138478L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.getWriter().println("Begin store service test.");

	}

	public static void main(String[] args) {
		// 狼牙
		/*
		 * String accessKeyId = "7SP7TlphQFz7rko4"; String accessKeySecret =
		 * "HbMUACXFPmY6jLvWUDvb3ALrvWan4j";
		 */

		// 成都网客
		String accessKeyId = "mOjl8ioofR4CZJEP";
		String accessKeySecret = "QbqOaz4Dr9HZQtPXDZmEC5ZERfxtU1";
		
		String endpoint = "http://oss-cn-shenzhen.aliyuncs.com";

		OSSClient client = new OSSClient(endpoint, accessKeyId, accessKeySecret);
		// 获取用户的Bucket列表
		List<Bucket> buckets = client.listBuckets();

		// 遍历Bucket
		for (Bucket bucket : buckets) {
			System.out.println(bucket.getName());
		}
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
